package com.dk.demo.web.api;


import com.dk.base.common.model.DemoDTO;
import com.dk.common.defs.CommonDefs;
import com.dk.common.result.ApiResult;
import com.dk.demo.core.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping(CommonDefs.RESTFUL_URI_CONTEXT + "/demo")
public class DemoApi {


    @Autowired
    private DemoService demoService;


    @GetMapping("/list")
    public ApiResult<List<DemoDTO>> list() {
        return ApiResult.success(demoService.list());
    }

    @GetMapping("/listProxy")
    public ApiResult<List<DemoDTO>> listProxy() {
        return ApiResult.success(demoService.listProxy());
    }


    @PostMapping("/inset/{num}")
    public ApiResult<Integer> inset(@PathVariable Integer num) {
        return ApiResult.success(demoService.insert(num));
    }
}
